$(function(){

    //默认加载模板1
    $(".loadbox").load('static/app/liujb/templet/tuxing.html');

    //默认工作区设置
    setCenterbox();
    $(window).resize(function(){
        setCenterbox();
    });

 
    

})

//设置工作区大框位置
function setCenterbox(){
    var $box = $(".workbox");    
    var $boxin = $('.workCenter');
    var $left = $(".leftNavbar");
    var $right = $(".pageSetbox");
    var owinW = $(window).width();
    var owinH = $(window).height();

    var leftWidth = $left.width();
    var rightWidth = $right.width();

    var oleft = $(".leftNavbar .icon_slide").hasClass('on')?0:leftWidth;
    var oright = $(".pageSetbox .icon_slide").hasClass('on')?0:rightWidth;

    
    
    //中间区域变化
    $box.animate({left:oleft,right:oright}); 

    /*var workWidth = owinW - oleft - oright;
    var zoomNum = workWidth / 1920; 
    setZoom(zoomNum);
    */

}




//左侧收缩
function leftBarslide(el){
    var $box = $('.leftNavbar');
    var oBox_width = $box.width();
    var bool = $(el).hasClass('on');
    if(!bool){
        $box.animate({left:-oBox_width});  
        $(el).addClass('on');
    }else{
        $box.animate({left:0});    
        $(el).removeClass('on');
    }

    setCenterbox();
   
}

//右侧收缩
function rightBarslide(el){
    var $box = $('.pageSetbox');
    var $bottomBar = $(".controlPanel");
    var oBox_width = $box.width();
    var bool = $(el).hasClass('on');
    if(!bool){
        $box.animate({right:-oBox_width});  
        $(el).addClass('on');
        $bottomBar.animate({'paddingRight':0});
    }else{
        $box.animate({right:0});    
        $(el).removeClass('on');
        $bottomBar.animate({'paddingRight':360});
    }
    setCenterbox();

}


//删除确认
function  delConfirm(id){
    layer.confirm('确定要删除数据源：'+ id +'?<br>删除之后将无法恢复!', {
      btn: ['确认','取消'] //按钮
    }, function(){
        //删除操作

        layer.closeAll();
    }, function(){
        
    });
}

//新建数据
function newdata(){
    layer.open({
      type: 2,
      title: '新建数据',
      shadeClose: true,
      shade: 0.4,
      btn: ['完成'], 
      area: ['445px', '540px'],
      content: 'static/app/liujb/templet/dataform.html' //
    },function(){
        layer.msg('的确很重要', {icon: 1});
    }); 
}


